<template>
    <div>
        <div style="margin: 10px 0">
            <el-input style="width: 200px" placeholder="请输入班级或学院" suffix-icon="el-icon-search"
                      v-model="mycollege"></el-input>
            <el-input style="width: 200px" placeholder="请选择年级" suffix-icon="el-icon-position"
                      class="ml-5" v-model="grade"></el-input>
            <el-input style="width: 200px" placeholder="请输入学科" suffix-icon="el-icon-message"
                      class="ml-5" v-model="subject"></el-input>
            <el-button class="ml-5" type="primary" @click="load">搜索</el-button>
            <el-button class="ml-5" type="warning" @click="reset">重置</el-button>
        </div>

        <el-table :data="tableData" border stripe :header-cell-class-name="headerBg"
                  @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="id" label="ID" width="80"></el-table-column>
            <el-table-column prop="myclass" label="专业" width="140"></el-table-column>
            <el-table-column prop="college" label="学院" width="120"></el-table-column>
            <el-table-column prop="grade" label="年级" width="120"></el-table-column>
            <el-table-column prop="subject1" label="数据结构"></el-table-column>
            <el-table-column prop="subject2" label="计算机网络"></el-table-column>
            <el-table-column prop="subject3" label="软件测试"></el-table-column>
            <el-table-column prop="subject4" label="前端应用开发"></el-table-column>
            <el-table-column prop="avg" label="平均分"></el-table-column>
            <el-table-column prop="msg" label="留言"></el-table-column>
            <el-table-column label="操作" width="200" align="center">
                <template slot-scope="scope">
                    <el-button type="success" @click="handleEdit(scope.row)">编辑 <i class="el-icon-edit"></i>
                    </el-button>
                    <el-popconfirm
                            class="ml-5"
                            confirm-button-text='确定'
                            cancel-button-text='我再想想'
                            icon="el-icon-info"
                            icon-color="red"
                            title="您确定删除吗？"
                            @confirm="handleDel(scope.row.id)">
                        <el-button type="danger" slot="reference">删除 <i class="el-icon-remove-outline"></i>
                        </el-button>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    export default {
        name: "Score",
        data() {
            return {
                tableData: [],
                total: 0,
                pageNum: 1,
                pageSize: 10,
                mycollege: "",
                grade: "",
                subject: "",
                form: {},
                headerBg: 'headerBg'
            }
        },
        created() {
            this.load()
        },
        methods: {
            load() {
                this.request.get("/score/page", {
                    params: {
                        pageNum: this.pageNum,
                        pageSize: this.pageSize,
                        mycollege: this.mycollege,
                        grade: this.grade,
                        subject: this.subject
                    }
                }).then(res => {
                    this.tableData = res.data.records;
                    this.total = res.data.total
                })
            },
            reset() {
                this.mycollege = "";
                this.grade = "";
                this.subject = "";
                this.load()
            }
        }
    }
</script>

<style scoped>
    .headerBg {
        background: #eee !important;
    }
</style>
